class AuthModel {
  String userId;
  String accessToken;
  String accessTokenType;
  String refreshToken;
  DateTime expiredTime;

  AuthModel.fromJson(Map<String, dynamic> json)
      : userId = json['userId'],
        accessToken = json['accessToken'],
        accessTokenType = json['accessTokenType'],
        refreshToken = json['refreshToken'] ?? '',
        expiredTime = json['expiredTime'] == null
            ? DateTime.now().add(const Duration(days: 30))
            : DateTime.fromMillisecondsSinceEpoch(
                json['expiredTime'].toInt(),
                isUtc: false,
              );

  Map<String, dynamic> toJson() {
    return {
      'userId': userId,
      'accessToken': accessToken,
      'accessTokenType': accessTokenType,
      'refreshToken': refreshToken,
      'expiredTime': expiredTime.millisecondsSinceEpoch
    };
  }
}
